#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
const int N = 100005;
int n, r[N], cnt[N], ans;
bool vis[N];
struct node
{
    int att, tot;
    bool operator < (const node &x)const
    {
        return x.att < att;
    }
};
priority_queue<node> q; // attack
priority_queue<node> q2; // alive
int main()
{
    freopen("duel.in", "r", stdin);
    freopen("duel.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i ++)
    {
        cin >> r[i];
        cnt[r[i]] ++;
    }
    for (int i = 1; i <= n; i ++)
    {
        if (!vis[r[i]])
        {
            q.push((node){r[i], cnt[r[i]]});
            vis[r[i]] = 1;
        }
    }
    node x = q.top(); q.pop(); q2.push(x);
    /* (!q.empty())
    {
        cout << q.top().att << ' ' << q.top().tot << '\n';
        q.pop();
    }
    cout << "----------------" << '\n';
    while (!q2.empty())
    {
        cout << q2.top().att << ' ' << q2.top().tot << '\n';
        q2.pop();
    }*/
    while (!q.empty())
    {
        while (!q.empty() && !q2.empty() && q.top().att < q2.top().att)
        {
            node x = q.top();
            q.pop();
            q2.push(x);
        }
        while (!q.empty() && !q2.empty() && q.top().att == q2.top().att)
        {
            node x = q.top(), y = q2.top();
            q.pop(); q2.pop();
            y.tot += x.tot;
            q2.push(y);
        }
        if (q.empty()) break;
        node tmp = q.top(), tmp2 = q2.top();
        q.pop(); q2.pop();
        //cout << q.size() << ' ' << q2.size() << '\n';
        if (tmp.tot > tmp2.tot)
        {
            tmp.tot -= tmp2.tot;
            q2.push((node){tmp.att, tmp2.tot});
            q.push(tmp);
        }
        else if (tmp.tot == tmp2.tot) q2.push(tmp);
        else
        {
            tmp2.tot -= tmp.tot;
            q2.push(tmp); q2.push(tmp2);
        }
    }
    while (!q2.empty())
    {
        ans += q2.top().tot;
        q2.pop();
    }
    cout << ans << '\n';
    return 0;
}


/*
10
136 136 136 2417 136 136 2417 136 136 136

8
*/
